package us.hootpic.client.view;

import java.util.List;

import us.hootpic.client.resources.GlobalResources;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Hyperlink;

public class PhotoListView extends Composite {

	private static PhotoListViewUiBinder uiBinder = GWT
			.create(PhotoListViewUiBinder.class);
	@UiField FlexTable photoTable;
	@UiField Label loadingLabel;
	@UiField Hyperlink addNew;

	interface PhotoListViewUiBinder extends UiBinder<Widget, PhotoListView> {
	}

	public PhotoListView() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	private void displayPhotos(List<String> photos){
		int i=0;
		photoTable.clear();
		
		if(photos == null ||  photos.size() == 0){
			loadingLabel.setText("No Photos");
			return;
		}
		
		loadingLabel.setVisible(false);
		
		for (final String photo : photos){
			CheckBox chkbox = new CheckBox(photo);
			final Image propertyBtn = new Image(GlobalResources.RESOURCE.propertyButton());
			propertyBtn.setStyleName("pointer");
			
			photoTable.setWidget(i, 0, chkbox);
			photoTable.setWidget(i, 1, propertyBtn);
			photoTable.getCellFormatter().addStyleName(i, 0, "friendNameInList");
			i++;
		}
	}
}
